using NUnit.Framework;

namespace Rsdn.SmartApp.Observer
{
	[TestFixture]
	public class ObserverTest
	{
		[Test]
		public void FireTest()
		{
			var i = 0;
			using (var observable = new Observable<int>())
			{
				observable.Fire(1);
				Assert.AreEqual(0, i);

				using (observable.Subscribe(item => i += item))
				{
					observable.Fire(1);
					Assert.AreEqual(1, i);

					using (observable.Subscribe(item => i += item))
					{
						observable.Fire(1);
						Assert.AreEqual(3, i);
					}
				}

				i = 0;
				observable.Fire(1);
				Assert.AreEqual(0, i);
			}
		}
	}
}